---
title: 'Cypress.Keyboard | Cypress Documentation'
description: Set the default values for how the .type() command is executed in Cypress.
sidebar_label: Keyboard
sidebar_position: 150
---

<ProductHeading product="app" />

# Cypress.Keyboard

The Keyboard API allows you to access available `Keys` for use with [`cy.press()`](/api/commands/press) or to set the default values for how the
[.type()](/api/commands/type) command is executed.

## Syntax

```javascript
Cypress.Keyboard.Keys(key)
Cypress.Keyboard.defaults(options)
```

### Keys Arguments

<Icon name="angle-right" /> **key _(String)_**

The key available for `cy.press()`.

The following keys are supported:

| Reference                         | Value                                                                |
| --------------------------------- | -------------------------------------------------------------------- |
| Letters                           | `"a"` through `"z"`, `"A"` through `"Z"`                             |
| Numbers                           | `"0"`, `"1"`, `"2"`, `"3"`, `"4"`, `"5"`, `"6"`, `"7"`, `"8"`, `"9"` |
| Special Characters                | `"!"`, `"@"`, `"#"`, `'+'`, `"€"`, `"é"`, etc.                       |
| `Cypress.Keyboard.Keys.UP`        | `"ArrowUp"`                                                          |
| `Cypress.Keyboard.Keys.DOWN`      | `"ArrowDown"`                                                        |
| `Cypress.Keyboard.Keys.LEFT`      | `"ArrowLeft"`                                                        |
| `Cypress.Keyboard.Keys.RIGHT`     | `"ArrowRight"`                                                       |
| `Cypress.Keyboard.Keys.ESC`       | `"Escape"`                                                           |
| `Cypress.Keyboard.Keys.END`       | `"End"`                                                              |
| `Cypress.Keyboard.Keys.HOME`      | `"Home"`                                                             |
| `Cypress.Keyboard.Keys.PAGEDOWN`  | `"PageDown"`                                                         |
| `Cypress.Keyboard.Keys.PAGEUP`    | `"PageUp"`                                                           |
| `Cypress.Keyboard.Keys.ENTER`     | `"Enter"`                                                            |
| `Cypress.Keyboard.Keys.TAB`       | `"Tab"`                                                              |
| `Cypress.Keyboard.Keys.BACKSPACE` | `"Backspace"`                                                        |
| `Cypress.Keyboard.Keys.DELETE`    | `"Delete"`                                                           |
| `Cypress.Keyboard.Keys.INSERT`    | `"Insert"`                                                           |
| `Cypress.Keyboard.Keys.SPACE`     | `"Space"`                                                            |

### defaults Arguments

<Icon name="angle-right" /> **options _(Object)_**

An object containing the following:

| Option           | Default | Description                                                                                                                                                    |
| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `keystrokeDelay` | `10`    | The delay, in milliseconds, between keystrokes while typing with [.type()](/api/commands/type). Set to `0` to remove the delay. Must be a non-negative number. |

## Examples

### Press tab key

```javascript
cy.press(Cypress.Keyboard.Keys.TAB)
cy.get('input.second').should('have.focus')
```

### Slow down typing by increasing the keystroke delay

```javascript
Cypress.Keyboard.defaults({
  keystrokeDelay: 20,
})
```

### Remove the keystroke delay

```javascript
Cypress.Keyboard.defaults({
  keystrokeDelay: 0,
})
```

## Notes

### Where to put Keyboard configuration

<SupportFileConfiguration />

### Set the keystroke delay in test configuration

The keystroke delay can also be set via
[test configuration](/app/core-concepts/writing-and-organizing-tests#Test-Configuration),
which can be useful when setting it for a single test or a subset of tests.

```javascript
it(
  'removes keystroke delay for all typing in this test',
  { keystrokeDelay: 0 },
  () => {
    cy.get('input').eq(0).type('fast typing')
    cy.get('input').eq(1).type('more fast typing')
  }
)

describe(
  'removes keystroke delay in all tests in this suite',
  { keystrokeDelay: 0 },
  () => {
    it('types fast in the first input', () => {
      cy.get('input').eq(0).type('fast typing')
    })

    it('types fast in the second input', () => {
      cy.get('input').eq(1).type('more fast typing')
    })
  }
)
```

## See also

- [`cy.press()`](/api/commands/press)
- [`.type()`](/api/commands/type)
